package cate.common.table.activity.exorcism.sheet;


import cate.common.table.ESheet;
import cate.common.table.activity.exorcism.row.ExorcismGhostRow;
import cate.common.util.random.RWList;
import easy.java.dev.note.NoteClass;

import java.util.HashMap;
import java.util.Map;

@NoteClass("驱魔之夜-小鬼")
public class ExorcismGhostSheet extends ESheet<ExorcismGhostRow> {

    @Override
    public String getSheetName() {
        return "小鬼";
    }


    private Map<Integer,RWList<ExorcismGhostRow>> rwMap;

    protected void onLoaded() {
        rwMap = new HashMap<>();
        for (ExorcismGhostRow row : this.getList()) {
            RWList<ExorcismGhostRow> rwList = rwMap.get(row.configTid);
            if (rwList == null) {
                rwList = new RWList<>();
                rwMap.put(row.configTid, rwList);
            }
            rwList.add(row);
        }
        for (RWList<ExorcismGhostRow> value : rwMap.values()) {
            value.setup();
        }
    }

    public ExorcismGhostRow random(int configTid) {
        RWList<ExorcismGhostRow> rwList = rwMap.get(configTid);
        if (rwList == null) {
            return null;
        }
        return rwList.get();
    }
}
